Class Wmi
	Private strLogin
	
	Public Property Let Login(ByVal varValue)
		strLogin = varValue
	End Property
	
	Public Property Get Login
		Login = strLogin
	End Property
	
	Private strPassword
	
	Public Property Let Password(ByVal varValue)
		strPassword = varValue
	End Property
	
	Public Property Get Password
		Password = strPassword
	End Property
	
	Private strIpAddress
	
	Public Property Let IpAddress(ByVal varValue)
		strIpAddress = varValue
	End Property
	
	Public Property Get IpAddress
		IpAddress = strIpAddress
	End Property
	
	Private strWmiPath
	
	Public Property Let WmiPath(ByVal varValue)
		strWmiPath = varValue
	End Property
	
	Public Property Get WmiPath
		WmiPath = strWmiPath
	End Property
	
	Private objWmiService
	
	Public Property Get WmiService
		Set WmiService = objWmiService
	End Property
	
	Public Sub Connect()
		Const WbemAuthenticationLevelPktPrivacy = 6
	
		If strIpAddress = Empty Then
			Err.Raise 5000, "Wmi->Connect()", "IpAddress"
		End If
		
		If strWmiPath = Empty Then
			Err.Raise 5000, "Wmi->Connect()", "WmiPath"
		End If
		
		On Error Resume Next
		
			Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
			
			objSWbemLocator.Security_.AuthenticationLevel = WbemAuthenticationLevelPktPrivacy
			
			If strLogin <> Empty and strPassword <> Empty Then
				Set objWMIService = objSWbemLocator.ConnectServer(strIpAddress, strWmiPath, strLogin, strPassword)
			Else
				Set objWMIService = objSWbemLocator.ConnectServer(strIpAddress, strWmiPath)
			End If
			
			arrError = Array(Err.Number, Err.Description)
		
		On Error Goto 0
		
		If arrError(0) <> 0 Then
			Err.Raise 5000, "Wmi->Connect()", "The connection to remote wmi service couldn't be made. Check your credentials"
		End If
	End Sub
End Class